
class Error(Exception):
    """Base class for exceptions in this module."""
    pass

class ValidationError(Error):
    """Exception raised for errors in the input.

    Attributes:
        expr -- input expression in which the error occurred
        msg  -- explanation of the error
    """

    def __init__(self, msg):
        #self.expr = expr
        self.msg = msg

    def __str__(self): 
        return self.msg


def validate_partition_threshold(value_str):
    conv_val = float(value_str.strip())
    if conv_val < 0 or conv_val > 1:
        raise ValidationError("Not a value between 0 and 1.")
    
def validate_significance_level(value_str):
    conv_val = float(value_str.strip())
    if conv_val < 0:
        raise ValidationError("Invalid value: "+conv_val)
    
def validate_snp_name(name):
    if not name.lower().startswith("rs"):
        raise ValidationError("Invalid SNP name: %s. Must begin with letters rs." % name)
    if not name.isalnum():
        raise ValidationError("Invalid SNP name: %s. Name must consist of alphanumeric chars." % name)
    
    
    